<!DOCTYPE html>
<html lang="zh-cn">
<head>
   
    <link type="text/css" rel="stylesheet" href="/bundles/blog-common.css?v=KOZafwuaDasEedEenI5aTy8aXH0epbm6VUJ0v3vsT_Q1"/>
<link id="MainCss" type="text/css" rel="stylesheet" href="/skins/ThinkInside/bundle-ThinkInside.css?v=RRjf6pEarGnbXZ86qxNycPfQivwSKWRa4heYLB15rVE1"/>
<link type="text/css" rel="stylesheet" href="/blog/customcss/428549.css?v=%2fam3bBTkW5NBWhBE%2fD0lcyJv5UM%3d"/>

</head>
<body>
<a name="top"></a>

<div id="page_begin_html"></div><script>load_page_begin_html();</script>

<div id="topics">
	<div class = "post">
		<h1 class = "postTitle">
			<a id="cb_post_title_url" class="postTitle2" href="https://www.cnblogs.com/frankdeng/p/9310204.html">HBase（四）HBase集群Shell操作</a>
		</h1>
		<div class="clear"></div>
		<div class="postBody">
			<div id="cnblogs_post_body" class="blogpost-body"><h2>一、进入HBase命令行</h2>
<p>在你安装的随意台服务器节点上，执行命令：hbase shell，会进入到你的 hbase shell 客 户端</p>
<div class="cnblogs_code">
<pre>[admin@node21 ~<span style="color: #000000;">]$ hbase shell</span><span style="color: #000000;">
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding </span><span style="color: #0000ff;">in</span> [jar:file:/opt/module/hbase-<span style="color: #800080;">1.2</span>.<span style="color: #800080;">6</span>/lib/slf4j-log4j12-<span style="color: #800080;">1.7</span>.<span style="color: #800080;">5</span>.jar!/org/slf4j/impl/StaticLoggerBinder.<span style="color: #0000ff;">class</span><span style="color: #000000;">]
SLF4J: Found binding </span><span style="color: #0000ff;">in</span> [jar:file:/opt/module/hadoop-<span style="color: #800080;">2.7</span>.<span style="color: #800080;">6</span>/share/hadoop/common/lib/slf4j-log4j12-<span style="color: #800080;">1.7</span>.<span style="color: #800080;">10</span>.jar!/org/slf4j/impl/StaticLoggerBinder.<span style="color: #0000ff;">class</span><span style="color: #000000;">]
SLF4J: See http:</span><span style="color: #008000;">//</span><span style="color: #008000;">www.slf4j.org/codes.html#multiple_bindings for an explanation.</span>
SLF4J: Actual binding <span style="color: #0000ff;">is</span><span style="color: #000000;"> of type [org.slf4j.impl.Log4jLoggerFactory]
HBase Shell; enter </span><span style="color: #800000;">'</span><span style="color: #800000;">help&lt;RETURN&gt;</span><span style="color: #800000;">'</span> <span style="color: #0000ff;">for</span><span style="color: #000000;"> list of supported commands.
Type </span><span style="color: #800000;">"</span><span style="color: #800000;">exit&lt;RETURN&gt;</span><span style="color: #800000;">"</span><span style="color: #000000;"> to leave the HBase Shell
Version </span><span style="color: #800080;">1.2</span>.<span style="color: #800080;">6</span>, rUnknown, Mon May <span style="color: #800080;">29</span> <span style="color: #800080;">02</span>:<span style="color: #800080;">25</span>:<span style="color: #800080;">32</span> CDT <span style="color: #800080;">2017<br /><br /></span></pre>
<pre>1.8.7-p357 :001 &gt;&nbsp;</pre>
</div>
<p>&nbsp;说明，先看一下提示。其实是不是有一句很重要的话：</p>
<div class="cnblogs_code">
<pre>HBase Shell; enter 'help&lt;RETURN&gt;' for list of supported commands.
Type "exit&lt;RETURN&gt;" to leave the HBase Shell</pre>
</div>
<p>讲述了怎么获得帮助，怎么退出客户端</p>
<p>help 获取帮助</p>
<p>　　help：获取所有命令提示</p>
<p>　　help "dml" ：获取一组命令的提示</p>
<p>　　help "put" ：获取一个单独命令的提示帮助</p>
<p>exit 退出 hbase shell 客户端</p>
<h2>二、HBase表的操作</h2>
<p>&nbsp; 这些是关于HBase在表中操作的命令。</p>
<ul>
<li><strong>create: </strong>创建一个表。</li>
<li><strong>list: </strong>列出HBase的所有表。</li>
<li><strong>disable: </strong>禁用表。</li>
<li><strong>is_disabled: </strong>验证表是否被禁用。</li>
<li><strong>enable: </strong>启用一个表。</li>
<li><strong>is_enabled: </strong>验证表是否已启用。</li>
<li><strong>describe: </strong>提供了一个表的描述。</li>
<li><strong>alter: </strong>改变一个表。</li>
<li><strong>exists: </strong>验证表是否存在。</li>
<li><strong>drop: </strong>从HBase中删除表。</li>
<li><strong>drop_all: </strong>丢弃在命令中给出匹配&ldquo;regex&rdquo;的表。</li>
<li><strong>Java Admin API: </strong>在此之前所有的上述命令，Java提供了一个通过API编程来管理实现DDL功能。在这个org.apache.hadoop.hbase.client包中有HBaseAdmin和HTableDescriptor 这两个重要的类提供DDL功能。</li>
</ul>
<p>&nbsp;关于表的操作包括（创建create，查看表列表list。查看表的详细信息desc，删除表drop，清空表truncate，修改表的定义alter）</p>
<h3>1、创建表create</h3>
<p>可以输入以下命令进行查看帮助命令</p>
<div class="cnblogs_code">
<pre>1.8.7-p357 :001 &gt;&nbsp;help 'create'</pre>
</div>
<div class="cnblogs_code">
<pre>Creates a table. Pass a table name, and a <span style="color: #0000ff;">set</span><span style="color: #000000;"> of column family
specifications (at least one), and, optionally, table configuration.
Column specification can be a simple </span><span style="color: #0000ff;">string</span><span style="color: #000000;"> (name), or a dictionary
(dictionaries are described below </span><span style="color: #0000ff;">in</span><span style="color: #000000;"> main help output), necessarily 
including NAME attribute. 
Examples:

Create a table with </span><span style="color: #0000ff;">namespace</span>=ns1 and table qualifier=<span style="color: #000000;">t1
  hbase</span>&gt; create <span style="color: #800000;">'</span><span style="color: #800000;">ns1:t1</span><span style="color: #800000;">'</span>, {NAME =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">f1</span><span style="color: #800000;">'</span>, VERSIONS =&gt; <span style="color: #800080;">5</span><span style="color: #000000;">}

Create a table with </span><span style="color: #0000ff;">namespace</span>=<span style="color: #0000ff;">default</span> and table qualifier=<span style="color: #000000;">t1
  hbase</span>&gt; create <span style="color: #800000;">'</span><span style="color: #800000;">t1</span><span style="color: #800000;">'</span>, {NAME =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">f1</span><span style="color: #800000;">'</span>}, {NAME =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">f2</span><span style="color: #800000;">'</span>}, {NAME =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">f3</span><span style="color: #800000;">'</span><span style="color: #000000;">}
  hbase</span>&gt; # The above <span style="color: #0000ff;">in</span><span style="color: #000000;"> shorthand would be the following:
  hbase</span>&gt; create <span style="color: #800000;">'</span><span style="color: #800000;">t1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">f1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">f2</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">f3</span><span style="color: #800000;">'</span><span style="color: #000000;">
  hbase</span>&gt; create <span style="color: #800000;">'</span><span style="color: #800000;">t1</span><span style="color: #800000;">'</span>, {NAME =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">f1</span><span style="color: #800000;">'</span>, VERSIONS =&gt; <span style="color: #800080;">1</span>, TTL =&gt; <span style="color: #800080;">2592000</span>, BLOCKCACHE =&gt; <span style="color: #0000ff;">true</span><span style="color: #000000;">}
  hbase</span>&gt; create <span style="color: #800000;">'</span><span style="color: #800000;">t1</span><span style="color: #800000;">'</span>, {NAME =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">f1</span><span style="color: #800000;">'</span>, CONFIGURATION =&gt; {<span style="color: #800000;">'</span><span style="color: #800000;">hbase.hstore.blockingStoreFiles</span><span style="color: #800000;">'</span> =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">10</span><span style="color: #800000;">'</span><span style="color: #000000;">}}
  
Table configuration options can be put at the end.
Examples:

  hbase</span>&gt; create <span style="color: #800000;">'</span><span style="color: #800000;">ns1:t1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">f1</span><span style="color: #800000;">'</span>, SPLITS =&gt; [<span style="color: #800000;">'</span><span style="color: #800000;">10</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">20</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">30</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">40</span><span style="color: #800000;">'</span><span style="color: #000000;">]
  hbase</span>&gt; create <span style="color: #800000;">'</span><span style="color: #800000;">t1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">f1</span><span style="color: #800000;">'</span>, SPLITS =&gt; [<span style="color: #800000;">'</span><span style="color: #800000;">10</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">20</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">30</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">40</span><span style="color: #800000;">'</span><span style="color: #000000;">]
  hbase</span>&gt; create <span style="color: #800000;">'</span><span style="color: #800000;">t1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">f1</span><span style="color: #800000;">'</span>, SPLITS_FILE =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">splits.txt</span><span style="color: #800000;">'</span>, OWNER =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">johndoe</span><span style="color: #800000;">'</span><span style="color: #000000;">
  hbase</span>&gt; create <span style="color: #800000;">'</span><span style="color: #800000;">t1</span><span style="color: #800000;">'</span>, {NAME =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">f1</span><span style="color: #800000;">'</span>, VERSIONS =&gt; <span style="color: #800080;">5</span>}, METADATA =&gt; { <span style="color: #800000;">'</span><span style="color: #800000;">mykey</span><span style="color: #800000;">'</span> =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">myvalue</span><span style="color: #800000;">'</span><span style="color: #000000;"> }
  hbase</span>&gt; # Optionally pre-split the table into NUMREGIONS, <span style="color: #0000ff;">using</span><span style="color: #000000;">
  hbase</span>&gt; # SPLITALGO (<span style="color: #800000;">"</span><span style="color: #800000;">HexStringSplit</span><span style="color: #800000;">"</span>, <span style="color: #800000;">"</span><span style="color: #800000;">UniformSplit</span><span style="color: #800000;">"</span><span style="color: #000000;"> or classname)
  hbase</span>&gt; create <span style="color: #800000;">'</span><span style="color: #800000;">t1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">f1</span><span style="color: #800000;">'</span>, {NUMREGIONS =&gt; <span style="color: #800080;">15</span>, SPLITALGO =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">HexStringSplit</span><span style="color: #800000;">'</span><span style="color: #000000;">}
  hbase</span>&gt; create <span style="color: #800000;">'</span><span style="color: #800000;">t1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">f1</span><span style="color: #800000;">'</span>, {NUMREGIONS =&gt; <span style="color: #800080;">15</span>, SPLITALGO =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">HexStringSplit</span><span style="color: #800000;">'</span>, REGION_REPLICATION =&gt; <span style="color: #800080;">2</span>, CONFIGURATION =&gt; {<span style="color: #800000;">'</span><span style="color: #800000;">hbase.hregion.scan.loadColumnFamiliesOnDemand</span><span style="color: #800000;">
'</span><span style="color: #800000;"> =&gt; </span><span style="color: #800000;">'</span><span style="color: #0000ff;">true</span><span style="color: #800000;">'</span><span style="color: #800000;">}}  hbase&gt; create </span><span style="color: #800000;">'</span>t1<span style="color: #800000;">'</span><span style="color: #800000;">, {NAME =&gt; </span><span style="color: #800000;">'</span>f1<span style="color: #800000;">'</span><span style="color: #800000;">, DFS_REPLICATION =&gt; 1}</span>
<span style="color: #000000;">
You can also keep around a reference to the created table:

  hbase</span>&gt; t1 = create <span style="color: #800000;">'</span><span style="color: #800000;">t1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">f1</span><span style="color: #800000;">'</span><span style="color: #000000;">

Which gives you a reference to the table named </span><span style="color: #800000;">'</span><span style="color: #800000;">t1</span><span style="color: #800000;">'</span><span style="color: #000000;">, on which you can then
call methods.
</span><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">002</span> &gt; </pre>
</div>
<p>可以看到其中一条提示</p>
<div class="cnblogs_code">
<pre>hbase&gt; create 't1', {NAME =&gt; 'f1'}, {NAME =&gt; 'f2'}, {NAME =&gt; 'f3'}</pre>
</div>
<p>其中t1是表名，f1,f2,f3是列簇的名，如：</p>
<div class="cnblogs_code">
<pre><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">002</span> &gt; create <span style="color: #800000;">'</span><span style="color: #800000;">myHbase</span><span style="color: #800000;">'</span>,{NAME =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">myCard</span><span style="color: #800000;">'</span>,VERSIONS =&gt; <span style="color: #800080;">5</span><span style="color: #000000;">}
</span><span style="color: #800080;">0</span> row(s) <span style="color: #0000ff;">in</span> <span style="color: #800080;">9.1260</span><span style="color: #000000;"> seconds

 </span>=&gt; Hbase::Table -<span style="color: #000000;"> myHbase 
</span><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">003</span> &gt; </pre>
</div>
<p>创建了一个名为myHbase的表，表里面有1个列簇，名为<strong>myCard</strong>，保留5个版本信息</p>
<h3>2、查看表列表list</h3>
<p>可以输入以下命令进行查看帮助命令</p>
<div class="cnblogs_code">
<pre><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">003</span> &gt; help <span style="color: #800000;">'</span><span style="color: #800000;">list</span><span style="color: #800000;">'</span><span style="color: #000000;">
List all tables </span><span style="color: #0000ff;">in</span><span style="color: #000000;"> hbase. Optional regular expression parameter could
be used to filter the output. Examples:

  hbase</span>&gt;<span style="color: #000000;"> list
  hbase</span>&gt; list <span style="color: #800000;">'</span><span style="color: #800000;">abc.*</span><span style="color: #800000;">'</span><span style="color: #000000;">
  hbase</span>&gt; list <span style="color: #800000;">'</span><span style="color: #800000;">ns:abc.*</span><span style="color: #800000;">'</span><span style="color: #000000;">
  hbase</span>&gt; list <span style="color: #800000;">'</span><span style="color: #800000;">ns:.*</span><span style="color: #800000;">'</span>
<span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">004</span> &gt; </pre>
</div>
<p>直接输入list进行查看</p>
<div class="cnblogs_code">
<pre><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">004</span> &gt;<span style="color: #000000;"> list
TABLE                                                                                                                                                                                                                                                                                                                      
myHbase                                                                                                                                                                                                                                                                                                                                
</span><span style="color: #800080;">1</span> row(s) <span style="color: #0000ff;">in</span> <span style="color: #800080;">0.0610</span><span style="color: #000000;"> seconds

 </span>=&gt; [<span style="color: #800000;">"</span><span style="color: #800000;">myHbase</span><span style="color: #800000;">"</span><span style="color: #000000;">] 
</span><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">005</span> &gt; </pre>
</div>
<p>只有一条结果，就是刚刚创建的表myHbase</p>
<h3>3、查看表详细信息desc</h3>
<p>一个大括号，就相当于一个列簇。</p>
<div class="cnblogs_code">
<pre><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">005</span> &gt; desc <span style="color: #800000;">'</span><span style="color: #800000;">myHbase</span><span style="color: #800000;">'</span><span style="color: #000000;">
Table myHbase </span><span style="color: #0000ff;">is</span><span style="color: #000000;"> ENABLED                                                                                                                                               
myHbase                                                                                                                                                                
COLUMN FAMILIES DESCRIPTION                                                                                                                                            
{NAME </span>=&gt; <span style="color: #800000;">'</span><span style="color: #800000;">myCard</span><span style="color: #800000;">'</span>, BLOOMFILTER =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">ROW</span><span style="color: #800000;">'</span>, VERSIONS =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">5</span><span style="color: #800000;">'</span>, IN_MEMORY =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">false</span><span style="color: #800000;">'</span>, KEEP_DELETED_CELLS =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">FALSE</span><span style="color: #800000;">'</span>, DATA_BLOCK_ENCODING =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">NONE</span><span style="color: #800000;">'</span>, TTL =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">FOREVER</span><span style="color: #800000;">'</span><span style="color: #000000;">, COMPRES
SION </span>=&gt; <span style="color: #800000;">'</span><span style="color: #800000;">NONE</span><span style="color: #800000;">'</span>, MIN_VERSIONS =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">0</span><span style="color: #800000;">'</span>, BLOCKCACHE =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">true</span><span style="color: #800000;">'</span>, BLOCKSIZE =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">65536</span><span style="color: #800000;">'</span>, REPLICATION_SCOPE =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">0</span><span style="color: #800000;">'</span><span style="color: #000000;">}                                                             
</span><span style="color: #800080;">1</span> row(s) <span style="color: #0000ff;">in</span> <span style="color: #800080;">0.5470</span><span style="color: #000000;"> seconds

</span><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">006</span> &gt; </pre>
</div>
<h3>4、修改表定义alter</h3>
<h4>添加一个列簇</h4>
<div class="cnblogs_code">
<pre><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">006</span> &gt; alter <span style="color: #800000;">'</span><span style="color: #800000;">myHbase</span><span style="color: #800000;">'</span>, NAME =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">myInfo</span><span style="color: #800000;">'</span><span style="color: #000000;">
Updating all regions with the </span><span style="color: #0000ff;">new</span><span style="color: #000000;"> schema...
</span><span style="color: #800080;">0</span>/<span style="color: #800080;">1</span><span style="color: #000000;"> regions updated.
</span><span style="color: #800080;">1</span>/<span style="color: #800080;">1</span><span style="color: #000000;"> regions updated.
Done.
</span><span style="color: #800080;">0</span> row(s) <span style="color: #0000ff;">in</span> <span style="color: #800080;">3.6430</span><span style="color: #000000;"> seconds

</span><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">007</span> &gt; desc <span style="color: #800000;">'</span><span style="color: #800000;">myHbase</span><span style="color: #800000;">'</span><span style="color: #000000;">
Table myHbase </span><span style="color: #0000ff;">is</span><span style="color: #000000;"> ENABLED                                                                                                                                               
myHbase                                                                                                                                                                
COLUMN FAMILIES DESCRIPTION                                                                                                                                            
{NAME </span>=&gt; <span style="color: #800000;">'</span><span style="color: #800000;">myCard</span><span style="color: #800000;">'</span>, BLOOMFILTER =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">ROW</span><span style="color: #800000;">'</span>, VERSIONS =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">5</span><span style="color: #800000;">'</span>, IN_MEMORY =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">false</span><span style="color: #800000;">'</span>, KEEP_DELETED_CELLS =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">FALSE</span><span style="color: #800000;">'</span>, DATA_BLOCK_ENCODING =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">NONE</span><span style="color: #800000;">'</span>, TTL =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">FOREVER</span><span style="color: #800000;">'</span><span style="color: #000000;">, COMPRES
SION </span>=&gt; <span style="color: #800000;">'</span><span style="color: #800000;">NONE</span><span style="color: #800000;">'</span>, MIN_VERSIONS =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">0</span><span style="color: #800000;">'</span>, BLOCKCACHE =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">true</span><span style="color: #800000;">'</span>, BLOCKSIZE =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">65536</span><span style="color: #800000;">'</span>, REPLICATION_SCOPE =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">0</span><span style="color: #800000;">'</span><span style="color: #000000;">}                                                             
{NAME </span>=&gt; <span style="color: #800000;">'</span><span style="color: #800000;">myInfo</span><span style="color: #800000;">'</span>, BLOOMFILTER =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">ROW</span><span style="color: #800000;">'</span>, VERSIONS =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">1</span><span style="color: #800000;">'</span>, IN_MEMORY =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">false</span><span style="color: #800000;">'</span>, KEEP_DELETED_CELLS =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">FALSE</span><span style="color: #800000;">'</span>, DATA_BLOCK_ENCODING =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">NONE</span><span style="color: #800000;">'</span>, TTL =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">FOREVER</span><span style="color: #800000;">'</span><span style="color: #000000;">, COMPRES
SION </span>=&gt; <span style="color: #800000;">'</span><span style="color: #800000;">NONE</span><span style="color: #800000;">'</span>, MIN_VERSIONS =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">0</span><span style="color: #800000;">'</span>, BLOCKCACHE =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">true</span><span style="color: #800000;">'</span>, BLOCKSIZE =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">65536</span><span style="color: #800000;">'</span>, REPLICATION_SCOPE =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">0</span><span style="color: #800000;">'</span><span style="color: #000000;">}                                                             
</span><span style="color: #800080;">2</span> row(s) <span style="color: #0000ff;">in</span> <span style="color: #800080;">0.1080</span><span style="color: #000000;"> seconds

</span><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">008</span> &gt; </pre>
</div>
<h4>删除一个列簇</h4>
<div class="cnblogs_code">
<pre><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">008</span> &gt; alter <span style="color: #800000;">'</span><span style="color: #800000;">myHbase</span><span style="color: #800000;">'</span>, NAME =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">myCard</span><span style="color: #800000;">'</span>, METHOD =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">delete</span><span style="color: #800000;">'</span><span style="color: #000000;">
Updating all regions with the </span><span style="color: #0000ff;">new</span><span style="color: #000000;"> schema...
</span><span style="color: #800080;">1</span>/<span style="color: #800080;">1</span><span style="color: #000000;"> regions updated.
Done.
</span><span style="color: #800080;">0</span> row(s) <span style="color: #0000ff;">in</span> <span style="color: #800080;">2.7110</span><span style="color: #000000;"> seconds

</span><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">009</span> &gt; desc <span style="color: #800000;">'</span><span style="color: #800000;">myHbase</span><span style="color: #800000;">'</span><span style="color: #000000;">
Table myHbase </span><span style="color: #0000ff;">is</span><span style="color: #000000;"> ENABLED                                                                                                                                               
myHbase                                                                                                                                                                
COLUMN FAMILIES DESCRIPTION                                                                                                                                            
{NAME </span>=&gt; <span style="color: #800000;">'</span><span style="color: #800000;">myInfo</span><span style="color: #800000;">'</span>, BLOOMFILTER =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">ROW</span><span style="color: #800000;">'</span>, VERSIONS =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">1</span><span style="color: #800000;">'</span>, IN_MEMORY =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">false</span><span style="color: #800000;">'</span>, KEEP_DELETED_CELLS =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">FALSE</span><span style="color: #800000;">'</span>, DATA_BLOCK_ENCODING =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">NONE</span><span style="color: #800000;">'</span>, TTL =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">FOREVER</span><span style="color: #800000;">'</span><span style="color: #000000;">, COMPRES
SION </span>=&gt; <span style="color: #800000;">'</span><span style="color: #800000;">NONE</span><span style="color: #800000;">'</span>, MIN_VERSIONS =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">0</span><span style="color: #800000;">'</span>, BLOCKCACHE =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">true</span><span style="color: #800000;">'</span>, BLOCKSIZE =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">65536</span><span style="color: #800000;">'</span>, REPLICATION_SCOPE =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">0</span><span style="color: #800000;">'</span><span style="color: #000000;">}                                                             
</span><span style="color: #800080;">1</span> row(s) <span style="color: #0000ff;">in</span> <span style="color: #800080;">0.0510</span><span style="color: #000000;"> seconds

</span><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">010</span> &gt; </pre>
</div>
<p>删除一个列簇也可以执行以下命令</p>
<div class="cnblogs_code">
<pre><strong>alter 'myHbase', 'delete' =&gt; 'myCard'</strong></pre>
</div>
<h4>添加列簇hehe同时删除列簇myInfo</h4>
<div class="cnblogs_code">
<pre><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">010</span> &gt; alter <span style="color: #800000;">'</span><span style="color: #800000;">myHbase</span><span style="color: #800000;">'</span>, {NAME =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">hehe</span><span style="color: #800000;">'</span>}, {NAME =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">myInfo</span><span style="color: #800000;">'</span>, METHOD =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">delete</span><span style="color: #800000;">'</span><span style="color: #000000;">}
Updating all regions with the </span><span style="color: #0000ff;">new</span><span style="color: #000000;"> schema...
</span><span style="color: #800080;">1</span>/<span style="color: #800080;">1</span><span style="color: #000000;"> regions updated.
Done.
Updating all regions with the </span><span style="color: #0000ff;">new</span><span style="color: #000000;"> schema...
</span><span style="color: #800080;">0</span>/<span style="color: #800080;">1</span><span style="color: #000000;"> regions updated.
</span><span style="color: #800080;">1</span>/<span style="color: #800080;">1</span><span style="color: #000000;"> regions updated.
Done.
</span><span style="color: #800080;">0</span> row(s) <span style="color: #0000ff;">in</span> <span style="color: #800080;">5.5340</span><span style="color: #000000;"> seconds

</span><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">011</span> &gt; desc <span style="color: #800000;">'</span><span style="color: #800000;">myHbase</span><span style="color: #800000;">'</span><span style="color: #000000;">
Table myHbase </span><span style="color: #0000ff;">is</span><span style="color: #000000;"> ENABLED                                                                                                                                               
myHbase                                                                                                                                                                
COLUMN FAMILIES DESCRIPTION                                                                                                                                            
{NAME </span>=&gt; <span style="color: #800000;">'</span><span style="color: #800000;">hehe</span><span style="color: #800000;">'</span>, BLOOMFILTER =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">ROW</span><span style="color: #800000;">'</span>, VERSIONS =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">1</span><span style="color: #800000;">'</span>, IN_MEMORY =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">false</span><span style="color: #800000;">'</span>, KEEP_DELETED_CELLS =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">FALSE</span><span style="color: #800000;">'</span>, DATA_BLOCK_ENCODING =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">NONE</span><span style="color: #800000;">'</span>, TTL =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">FOREVER</span><span style="color: #800000;">'</span><span style="color: #000000;">, COMPRESSI
ON </span>=&gt; <span style="color: #800000;">'</span><span style="color: #800000;">NONE</span><span style="color: #800000;">'</span>, MIN_VERSIONS =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">0</span><span style="color: #800000;">'</span>, BLOCKCACHE =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">true</span><span style="color: #800000;">'</span>, BLOCKSIZE =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">65536</span><span style="color: #800000;">'</span>, REPLICATION_SCOPE =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">0</span><span style="color: #800000;">'</span><span style="color: #000000;">}                                                               
</span><span style="color: #800080;">1</span> row(s) <span style="color: #0000ff;">in</span> <span style="color: #800080;">0.0520</span><span style="color: #000000;"> seconds

</span><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">012</span> &gt; </pre>
</div>
<h3 style="text-align: left;">5、truncate清空表&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</h3>
<div class="cnblogs_code">
<pre><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">012</span> &gt; truncate <span style="color: #800000;">'</span><span style="color: #800000;">myHbase</span><span style="color: #800000;">'</span><span style="color: #000000;">
Truncating </span><span style="color: #800000;">'</span><span style="color: #800000;">myHbase</span><span style="color: #800000;">'</span> table (it may take a <span style="color: #0000ff;">while</span><span style="color: #000000;">):
 </span>-<span style="color: #000000;"> Disabling table...
 </span>-<span style="color: #000000;"> Truncating table...
</span><span style="color: #800080;">0</span> row(s) <span style="color: #0000ff;">in</span> <span style="color: #800080;">8.6040</span><span style="color: #000000;"> seconds

</span><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">013</span> &gt; </pre>
</div>
<h3>6、删除表drop</h3>
<div class="cnblogs_code">
<pre><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">013</span> &gt; drop <span style="color: #800000;">'</span><span style="color: #800000;">myHbase</span><span style="color: #800000;">'</span><span style="color: #000000;"><span style="color: #ff0000;">

ERROR:</span> Table myHbase </span><span style="color: #0000ff;">is</span><span style="color: #000000;"> enabled. Disable it first.

Here </span><span style="color: #0000ff;">is</span> some help <span style="color: #0000ff;">for</span> <span style="color: #0000ff;">this</span><span style="color: #000000;"> command:
Drop the named table. <span style="color: #ff0000;">Table must first be disabled</span>:
  hbase</span>&gt; drop <span style="color: #800000;">'</span><span style="color: #800000;">t1</span><span style="color: #800000;">'</span><span style="color: #000000;">
  hbase</span>&gt; drop <span style="color: #800000;">'</span><span style="color: #800000;">ns1:t1</span><span style="color: #800000;">'</span>


<span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">014</span> &gt; </pre>
</div>
<p>直接删除表会报错，根据提示需要先停用表</p>
<div class="cnblogs_code">
<pre><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">014</span> &gt; disable <span style="color: #800000;">'</span><span style="color: #800000;">myHbase</span><span style="color: #800000;">'</span>
<span style="color: #800080;">0</span> row(s) <span style="color: #0000ff;">in</span> <span style="color: #800080;">2.3470</span><span style="color: #000000;"> seconds

</span><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">015</span> &gt; drop <span style="color: #800000;">'</span><span style="color: #800000;">myHbase</span><span style="color: #800000;">'</span>
<span style="color: #800080;">0</span> row(s) <span style="color: #0000ff;">in</span> <span style="color: #800080;">1.3850</span><span style="color: #000000;"> seconds

</span><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">016</span> &gt;<span style="color: #000000;"> list
TABLE                                                                                                           
</span><span style="color: #800080;">0</span> row(s) <span style="color: #0000ff;">in</span> <span style="color: #800080;">0.0110</span><span style="color: #000000;"> seconds

</span>=&gt;<span style="color: #000000;"> []
</span><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">017</span> &gt;</pre>
</div>
<h2>三、HBase表中数据的操作</h2>
<ul>
<li><strong>put: </strong>把指定列在指定的行中单元格的值在一个特定的表。</li>
<li><strong>get: </strong>取行或单元格的内容。</li>
<li><strong>delete: </strong>删除表中的单元格值。</li>
<li><strong>deleteall:</strong> 删除给定行的所有单元格。</li>
<li><strong>scan:</strong> 扫描并返回表数据。</li>
<li><strong>count: </strong>计数并返回表中的行的数目。</li>
<li><strong>truncate: </strong>禁用，删除和重新创建一个指定的表。</li>
<li><strong>Java client API: </strong>在此之前所有上述命令，Java提供了一个客户端API来实现DML功能，CRUD（创建检索更新删除）操作更多的是通过编程，在org.apache.hadoop.hbase.client包下。 在此包HTable 的 Put和Get是重要的类。</li>
</ul>
<p>关于数据的操作（增put，删delete，查get + scan,&nbsp; 改==变相的增加）</p>
<p>创建 user 表，包含 info、data 两个列簇</p>
<div class="cnblogs_code">
<pre><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">017</span> &gt; create <span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>,{NAME=&gt;<span style="color: #800000;">'</span><span style="color: #800000;">base_info</span><span style="color: #800000;">'</span>,VERSIONS=&gt;<span style="color: #800080;">3</span> },{NAME=&gt;<span style="color: #800000;">'</span><span style="color: #800000;">extra_info</span><span style="color: #800000;">'</span>,VERSIONS=&gt;<span style="color: #800080;">1</span><span style="color: #000000;"> } 
</span><span style="color: #800080;">0</span> row(s) <span style="color: #0000ff;">in</span> <span style="color: #800080;">4.3020</span><span style="color: #000000;"> seconds

 </span>=&gt; Hbase::Table -<span style="color: #000000;"> user_info 
</span><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">018</span> &gt; </pre>
</div>
<h3>1、增put</h3>
<p>查看帮助，需要传入表名，rowkey，列簇名、值等</p>
<div class="cnblogs_code">
<pre><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">018</span> &gt; help <span style="color: #800000;">'</span><span style="color: #800000;">put</span><span style="color: #800000;">'</span><span style="color: #000000;">
Put a cell </span><span style="color: #800000;">'</span><span style="color: #800000;">value</span><span style="color: #800000;">'</span> at specified table/row/<span style="color: #000000;">column and optionally
timestamp coordinates.  To put a cell value into table </span><span style="color: #800000;">'</span><span style="color: #800000;">ns1:t1</span><span style="color: #800000;">'</span> or <span style="color: #800000;">'</span><span style="color: #800000;">t1</span><span style="color: #800000;">'</span><span style="color: #000000;">
at row </span><span style="color: #800000;">'</span><span style="color: #800000;">r1</span><span style="color: #800000;">'</span> under column <span style="color: #800000;">'</span><span style="color: #800000;">c1</span><span style="color: #800000;">'</span> marked with the time <span style="color: #800000;">'</span><span style="color: #800000;">ts1</span><span style="color: #800000;">'</span>, <span style="color: #0000ff;">do</span><span style="color: #000000;">:

  hbase</span>&gt; put <span style="color: #800000;">'</span><span style="color: #800000;">ns1:t1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">r1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">c1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">value</span><span style="color: #800000;">'</span><span style="color: #ff0000;">
  hbase&gt; put 't1', 'r1', 'c1', 'value'</span><span style="color: #000000;">
  hbase</span>&gt; put <span style="color: #800000;">'</span><span style="color: #800000;">t1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">r1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">c1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">value</span><span style="color: #800000;">'</span><span style="color: #000000;">, ts1
  hbase</span>&gt; put <span style="color: #800000;">'</span><span style="color: #800000;">t1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">r1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">c1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">value</span><span style="color: #800000;">'</span>, {ATTRIBUTES=&gt;{<span style="color: #800000;">'</span><span style="color: #800000;">mykey</span><span style="color: #800000;">'</span>=&gt;<span style="color: #800000;">'</span><span style="color: #800000;">myvalue</span><span style="color: #800000;">'</span><span style="color: #000000;">}}
  hbase</span>&gt; put <span style="color: #800000;">'</span><span style="color: #800000;">t1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">r1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">c1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">value</span><span style="color: #800000;">'</span>, ts1, {ATTRIBUTES=&gt;{<span style="color: #800000;">'</span><span style="color: #800000;">mykey</span><span style="color: #800000;">'</span>=&gt;<span style="color: #800000;">'</span><span style="color: #800000;">myvalue</span><span style="color: #800000;">'</span><span style="color: #000000;">}}
  hbase</span>&gt; put <span style="color: #800000;">'</span><span style="color: #800000;">t1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">r1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">c1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">value</span><span style="color: #800000;">'</span>, ts1, {VISIBILITY=&gt;<span style="color: #800000;">'</span><span style="color: #800000;">PRIVATE|SECRET</span><span style="color: #800000;">'</span><span style="color: #000000;">}

The same commands also can be run on a table reference. Suppose you had a reference
t to table </span><span style="color: #800000;">'</span><span style="color: #800000;">t1</span><span style="color: #800000;">'</span><span style="color: #000000;">, the corresponding command would be:

  hbase</span>&gt; t.put <span style="color: #800000;">'</span><span style="color: #800000;">r1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">c1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">value</span><span style="color: #800000;">'</span>, ts1, {ATTRIBUTES=&gt;{<span style="color: #800000;">'</span><span style="color: #800000;">mykey</span><span style="color: #800000;">'</span>=&gt;<span style="color: #800000;">'</span><span style="color: #800000;">myvalue</span><span style="color: #800000;">'</span><span style="color: #000000;">}}
</span><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">019</span> &gt; </pre>
</div>
<p>&nbsp;向 user 表中插入信息，row key 为 user0001，列簇 base_info 中添加 name 列标示符，值为 zhangsan1</p>
<div class="cnblogs_code">
<pre><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">019</span> &gt; put <span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">user0001</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">base_info:name</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">zhangsan1</span><span style="color: #800000;">'</span>
<span style="color: #800080;">0</span> row(s) <span style="color: #0000ff;">in</span> <span style="color: #800080;">0.6590</span><span style="color: #000000;"> seconds

</span><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">020</span> &gt; </pre>
</div>
<p>此处可以多添加几条数据</p>
<div class="cnblogs_code" onclick="cnblogs_code_show('f54e1b2a-b987-491a-9835-bc6085601681')"><img id="code_img_closed_f54e1b2a-b987-491a-9835-bc6085601681" class="code_img_closed" src="https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif" alt="" /><img id="code_img_opened_f54e1b2a-b987-491a-9835-bc6085601681" class="code_img_opened" style="display: none;" onclick="cnblogs_code_hide('f54e1b2a-b987-491a-9835-bc6085601681',event)" src="https://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif" alt="" />
<div id="cnblogs_code_open_f54e1b2a-b987-491a-9835-bc6085601681" class="cnblogs_code_hide">
<pre>put <span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">zhangsan_20150701_0001</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">base_info:name</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">zhangsan1</span><span style="color: #800000;">'</span><span style="color: #000000;">
put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">zhangsan_20150701_0002</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">base_info:name</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">zhangsan2</span><span style="color: #800000;">'</span><span style="color: #000000;">
put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">zhangsan_20150701_0003</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">base_info:name</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">zhangsan3</span><span style="color: #800000;">'</span><span style="color: #000000;">
put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">zhangsan_20150701_0004</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">base_info:name</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">zhangsan4</span><span style="color: #800000;">'</span><span style="color: #000000;">
put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">zhangsan_20150701_0005</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">base_info:name</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">zhangsan5</span><span style="color: #800000;">'</span><span style="color: #000000;">
put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">zhangsan_20150701_0006</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">base_info:name</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">zhangsan6</span><span style="color: #800000;">'</span><span style="color: #000000;">
put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">zhangsan_20150701_0007</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">base_info:name</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">zhangsan7</span><span style="color: #800000;">'</span><span style="color: #000000;">
put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">zhangsan_20150701_0008</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">base_info:name</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">zhangsan8</span><span style="color: #800000;">'</span><span style="color: #000000;">

put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">zhangsan_20150701_0001</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">base_info:age</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">21</span><span style="color: #800000;">'</span><span style="color: #000000;">
put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">zhangsan_20150701_0002</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">base_info:age</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">22</span><span style="color: #800000;">'</span><span style="color: #000000;">
put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">zhangsan_20150701_0003</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">base_info:age</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">23</span><span style="color: #800000;">'</span><span style="color: #000000;">
put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">zhangsan_20150701_0004</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">base_info:age</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">24</span><span style="color: #800000;">'</span><span style="color: #000000;">
put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">zhangsan_20150701_0005</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">base_info:age</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">25</span><span style="color: #800000;">'</span><span style="color: #000000;">
put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">zhangsan_20150701_0006</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">base_info:age</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">26</span><span style="color: #800000;">'</span><span style="color: #000000;">
put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">zhangsan_20150701_0007</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">base_info:age</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">27</span><span style="color: #800000;">'</span><span style="color: #000000;">
put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">zhangsan_20150701_0008</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">base_info:age</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">28</span><span style="color: #800000;">'</span><span style="color: #000000;">

put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">zhangsan_20150701_0001</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">extra_info:Hobbies</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">music</span><span style="color: #800000;">'</span><span style="color: #000000;">
put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">zhangsan_20150701_0002</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">extra_info:Hobbies</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">sport</span><span style="color: #800000;">'</span><span style="color: #000000;">
put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">zhangsan_20150701_0003</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">extra_info:Hobbies</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">music</span><span style="color: #800000;">'</span><span style="color: #000000;">
put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">zhangsan_20150701_0004</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">extra_info:Hobbies</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">sport</span><span style="color: #800000;">'</span><span style="color: #000000;">
put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">zhangsan_20150701_0005</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">extra_info:Hobbies</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">music</span><span style="color: #800000;">'</span><span style="color: #000000;">
put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">zhangsan_20150701_0006</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">extra_info:Hobbies</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">sport</span><span style="color: #800000;">'</span><span style="color: #000000;">
put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">zhangsan_20150701_0007</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">extra_info:Hobbies</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">music</span><span style="color: #800000;">'</span><span style="color: #000000;">

put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">baiyc_20150716_0001</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">base_info:name</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">baiyc1</span><span style="color: #800000;">'</span><span style="color: #000000;">
put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">baiyc_20150716_0002</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">base_info:name</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">baiyc2</span><span style="color: #800000;">'</span><span style="color: #000000;">
put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">baiyc_20150716_0003</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">base_info:name</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">baiyc3</span><span style="color: #800000;">'</span><span style="color: #000000;">
put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">baiyc_20150716_0004</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">base_info:name</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">baiyc4</span><span style="color: #800000;">'</span><span style="color: #000000;">
put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">baiyc_20150716_0005</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">base_info:name</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">baiyc5</span><span style="color: #800000;">'</span><span style="color: #000000;">
put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">baiyc_20150716_0006</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">base_info:name</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">baiyc6</span><span style="color: #800000;">'</span><span style="color: #000000;">
put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">baiyc_20150716_0007</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">base_info:name</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">baiyc7</span><span style="color: #800000;">'</span><span style="color: #000000;">
put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">baiyc_20150716_0008</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">base_info:name</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">baiyc8</span><span style="color: #800000;">'</span><span style="color: #000000;">

put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">baiyc_20150716_0001</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">base_info:age</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">21</span><span style="color: #800000;">'</span><span style="color: #000000;">
put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">baiyc_20150716_0002</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">base_info:age</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">22</span><span style="color: #800000;">'</span><span style="color: #000000;">
put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">baiyc_20150716_0003</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">base_info:age</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">23</span><span style="color: #800000;">'</span><span style="color: #000000;">
put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">baiyc_20150716_0004</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">base_info:age</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">24</span><span style="color: #800000;">'</span><span style="color: #000000;">
put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">baiyc_20150716_0005</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">base_info:age</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">25</span><span style="color: #800000;">'</span><span style="color: #000000;">
put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">baiyc_20150716_0006</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">base_info:age</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">26</span><span style="color: #800000;">'</span><span style="color: #000000;">
put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">baiyc_20150716_0007</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">base_info:age</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">27</span><span style="color: #800000;">'</span><span style="color: #000000;">
put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">baiyc_20150716_0008</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">base_info:age</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">28</span><span style="color: #800000;">'</span><span style="color: #000000;">

put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">baiyc_20150716_0001</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">extra_info:Hobbies</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">music</span><span style="color: #800000;">'</span><span style="color: #000000;">
put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">baiyc_20150716_0002</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">extra_info:Hobbies</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">sport</span><span style="color: #800000;">'</span><span style="color: #000000;">
put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">baiyc_20150716_0003</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">extra_info:Hobbies</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">music</span><span style="color: #800000;">'</span><span style="color: #000000;">
put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">baiyc_20150716_0004</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">extra_info:Hobbies</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">sport</span><span style="color: #800000;">'</span><span style="color: #000000;">
put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">baiyc_20150716_0005</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">extra_info:Hobbies</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">music</span><span style="color: #800000;">'</span><span style="color: #000000;">
put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">baiyc_20150716_0006</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">extra_info:Hobbies</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">sport</span><span style="color: #800000;">'</span><span style="color: #000000;">
put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">baiyc_20150716_0007</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">extra_info:Hobbies</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">music</span><span style="color: #800000;">'</span><span style="color: #000000;">
put </span><span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">baiyc_20150716_0008</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">extra_info:Hobbies</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">sport</span><span style="color: #800000;">'</span></pre>
</div>
<span class="cnblogs_code_collapse">View Code</span></div>
<h3>2、查get + scan</h3>
<p>help 'get'</p>
<div class="cnblogs_code" onclick="cnblogs_code_show('92d45256-086e-4c1c-a54c-daafe67503b8')"><img id="code_img_closed_92d45256-086e-4c1c-a54c-daafe67503b8" class="code_img_closed" src="https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif" alt="" /><img id="code_img_opened_92d45256-086e-4c1c-a54c-daafe67503b8" class="code_img_opened" style="display: none;" onclick="cnblogs_code_hide('92d45256-086e-4c1c-a54c-daafe67503b8',event)" src="https://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif" alt="" />
<div id="cnblogs_code_open_92d45256-086e-4c1c-a54c-daafe67503b8" class="cnblogs_code_hide">
<pre><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">074</span> &gt; help <span style="color: #800000;">'</span><span style="color: #800000;">get</span><span style="color: #800000;">'</span><span style="color: #000000;">
Get row or cell contents; pass table name, row, and optionally
a dictionary of column(s), timestamp, timerange and versions. Examples:

  hbase</span>&gt; <span style="color: #0000ff;">get</span> <span style="color: #800000;">'</span><span style="color: #800000;">ns1:t1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">r1</span><span style="color: #800000;">'</span><span style="color: #000000;">
  hbase</span>&gt; <span style="color: #0000ff;">get</span> <span style="color: #800000;">'</span><span style="color: #800000;">t1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">r1</span><span style="color: #800000;">'</span><span style="color: #000000;">
  hbase</span>&gt; <span style="color: #0000ff;">get</span> <span style="color: #800000;">'</span><span style="color: #800000;">t1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">r1</span><span style="color: #800000;">'</span>, {TIMERANGE =&gt;<span style="color: #000000;"> [ts1, ts2]}
  hbase</span>&gt; <span style="color: #0000ff;">get</span> <span style="color: #800000;">'</span><span style="color: #800000;">t1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">r1</span><span style="color: #800000;">'</span>, {COLUMN =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">c1</span><span style="color: #800000;">'</span><span style="color: #000000;">}
  hbase</span>&gt; <span style="color: #0000ff;">get</span> <span style="color: #800000;">'</span><span style="color: #800000;">t1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">r1</span><span style="color: #800000;">'</span>, {COLUMN =&gt; [<span style="color: #800000;">'</span><span style="color: #800000;">c1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">c2</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">c3</span><span style="color: #800000;">'</span><span style="color: #000000;">]}
  hbase</span>&gt; <span style="color: #0000ff;">get</span> <span style="color: #800000;">'</span><span style="color: #800000;">t1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">r1</span><span style="color: #800000;">'</span>, {COLUMN =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">c1</span><span style="color: #800000;">'</span>, TIMESTAMP =&gt;<span style="color: #000000;"> ts1}
  hbase</span>&gt; <span style="color: #0000ff;">get</span> <span style="color: #800000;">'</span><span style="color: #800000;">t1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">r1</span><span style="color: #800000;">'</span>, {COLUMN =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">c1</span><span style="color: #800000;">'</span>, TIMERANGE =&gt; [ts1, ts2], VERSIONS =&gt; <span style="color: #800080;">4</span><span style="color: #000000;">}
  hbase</span>&gt; <span style="color: #0000ff;">get</span> <span style="color: #800000;">'</span><span style="color: #800000;">t1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">r1</span><span style="color: #800000;">'</span>, {COLUMN =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">c1</span><span style="color: #800000;">'</span>, TIMESTAMP =&gt; ts1, VERSIONS =&gt; <span style="color: #800080;">4</span><span style="color: #000000;">}
  hbase</span>&gt; <span style="color: #0000ff;">get</span> <span style="color: #800000;">'</span><span style="color: #800000;">t1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">r1</span><span style="color: #800000;">'</span>, {FILTER =&gt; <span style="color: #800000;">"</span><span style="color: #800000;">ValueFilter(=, 'binary:abc')</span><span style="color: #800000;">"</span><span style="color: #000000;">}
  hbase</span>&gt; <span style="color: #0000ff;">get</span> <span style="color: #800000;">'</span><span style="color: #800000;">t1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">r1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">c1</span><span style="color: #800000;">'</span><span style="color: #000000;">
  hbase</span>&gt; <span style="color: #0000ff;">get</span> <span style="color: #800000;">'</span><span style="color: #800000;">t1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">r1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">c1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">c2</span><span style="color: #800000;">'</span><span style="color: #000000;">
  hbase</span>&gt; <span style="color: #0000ff;">get</span> <span style="color: #800000;">'</span><span style="color: #800000;">t1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">r1</span><span style="color: #800000;">'</span>, [<span style="color: #800000;">'</span><span style="color: #800000;">c1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">c2</span><span style="color: #800000;">'</span><span style="color: #000000;">]
  hbase</span>&gt; <span style="color: #0000ff;">get</span> <span style="color: #800000;">'</span><span style="color: #800000;">t1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">r1</span><span style="color: #800000;">'</span>, {COLUMN =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">c1</span><span style="color: #800000;">'</span>, ATTRIBUTES =&gt; {<span style="color: #800000;">'</span><span style="color: #800000;">mykey</span><span style="color: #800000;">'</span>=&gt;<span style="color: #800000;">'</span><span style="color: #800000;">myvalue</span><span style="color: #800000;">'</span><span style="color: #000000;">}}
  hbase</span>&gt; <span style="color: #0000ff;">get</span> <span style="color: #800000;">'</span><span style="color: #800000;">t1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">r1</span><span style="color: #800000;">'</span>, {COLUMN =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">c1</span><span style="color: #800000;">'</span>, AUTHORIZATIONS =&gt; [<span style="color: #800000;">'</span><span style="color: #800000;">PRIVATE</span><span style="color: #800000;">'</span>,<span style="color: #800000;">'</span><span style="color: #800000;">SECRET</span><span style="color: #800000;">'</span><span style="color: #000000;">]}
  hbase</span>&gt; <span style="color: #0000ff;">get</span> <span style="color: #800000;">'</span><span style="color: #800000;">t1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">r1</span><span style="color: #800000;">'</span>, {CONSISTENCY =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">TIMELINE</span><span style="color: #800000;">'</span><span style="color: #000000;">}
  hbase</span>&gt; <span style="color: #0000ff;">get</span> <span style="color: #800000;">'</span><span style="color: #800000;">t1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">r1</span><span style="color: #800000;">'</span>, {CONSISTENCY =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">TIMELINE</span><span style="color: #800000;">'</span>, REGION_REPLICA_ID =&gt; <span style="color: #800080;">1</span><span style="color: #000000;">}

Besides the </span><span style="color: #0000ff;">default</span> <span style="color: #800000;">'</span><span style="color: #800000;">toStringBinary</span><span style="color: #800000;">'</span> format, <span style="color: #800000;">'</span><span style="color: #800000;">get</span><span style="color: #800000;">'</span><span style="color: #000000;"> also supports custom formatting by
column.  A user can define a FORMATTER by adding it to the column name </span><span style="color: #0000ff;">in</span> the <span style="color: #0000ff;">get</span><span style="color: #000000;">
specification.  The FORMATTER can be stipulated: 

 </span><span style="color: #800080;">1</span>. either <span style="color: #0000ff;">as</span><span style="color: #000000;"> a org.apache.hadoop.hbase.util.Bytes method name (e.g, toInt, toString)
 </span><span style="color: #800080;">2</span>. or <span style="color: #0000ff;">as</span> a custom <span style="color: #0000ff;">class</span> followed by method name: e.g. <span style="color: #800000;">'</span><span style="color: #800000;">c(MyFormatterClass).format</span><span style="color: #800000;">'</span><span style="color: #000000;">.

Example formatting cf:qualifier1 and cf:qualifier2 both </span><span style="color: #0000ff;">as</span><span style="color: #000000;"> Integers: 
  hbase</span>&gt; <span style="color: #0000ff;">get</span> <span style="color: #800000;">'</span><span style="color: #800000;">t1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">r1</span><span style="color: #800000;">'</span> {COLUMN =&gt; [<span style="color: #800000;">'</span><span style="color: #800000;">cf:qualifier1:toInt</span><span style="color: #800000;">'</span><span style="color: #000000;">,
    </span><span style="color: #800000;">'</span><span style="color: #800000;">cf:qualifier2:c(org.apache.hadoop.hbase.util.Bytes).toInt</span><span style="color: #800000;">'</span><span style="color: #000000;">] } 

Note that you can specify a FORMATTER by column only (cf:qualifier).  You cannot specify
a FORMATTER </span><span style="color: #0000ff;">for</span><span style="color: #000000;"> all columns of a column family.
    
The same commands also can be run on a reference to a table (obtained via get_table or
create_table). Suppose you had a reference t to table </span><span style="color: #800000;">'</span><span style="color: #800000;">t1</span><span style="color: #800000;">'</span><span style="color: #000000;">, the corresponding commands
would be:

  hbase</span>&gt; t.<span style="color: #0000ff;">get</span> <span style="color: #800000;">'</span><span style="color: #800000;">r1</span><span style="color: #800000;">'</span><span style="color: #000000;">
  hbase</span>&gt; t.<span style="color: #0000ff;">get</span> <span style="color: #800000;">'</span><span style="color: #800000;">r1</span><span style="color: #800000;">'</span>, {TIMERANGE =&gt;<span style="color: #000000;"> [ts1, ts2]}
  hbase</span>&gt; t.<span style="color: #0000ff;">get</span> <span style="color: #800000;">'</span><span style="color: #800000;">r1</span><span style="color: #800000;">'</span>, {COLUMN =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">c1</span><span style="color: #800000;">'</span><span style="color: #000000;">}
  hbase</span>&gt; t.<span style="color: #0000ff;">get</span> <span style="color: #800000;">'</span><span style="color: #800000;">r1</span><span style="color: #800000;">'</span>, {COLUMN =&gt; [<span style="color: #800000;">'</span><span style="color: #800000;">c1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">c2</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">c3</span><span style="color: #800000;">'</span><span style="color: #000000;">]}
  hbase</span>&gt; t.<span style="color: #0000ff;">get</span> <span style="color: #800000;">'</span><span style="color: #800000;">r1</span><span style="color: #800000;">'</span>, {COLUMN =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">c1</span><span style="color: #800000;">'</span>, TIMESTAMP =&gt;<span style="color: #000000;"> ts1}
  hbase</span>&gt; t.<span style="color: #0000ff;">get</span> <span style="color: #800000;">'</span><span style="color: #800000;">r1</span><span style="color: #800000;">'</span>, {COLUMN =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">c1</span><span style="color: #800000;">'</span>, TIMERANGE =&gt; [ts1, ts2], VERSIONS =&gt; <span style="color: #800080;">4</span><span style="color: #000000;">}
  hbase</span>&gt; t.<span style="color: #0000ff;">get</span> <span style="color: #800000;">'</span><span style="color: #800000;">r1</span><span style="color: #800000;">'</span>, {COLUMN =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">c1</span><span style="color: #800000;">'</span>, TIMESTAMP =&gt; ts1, VERSIONS =&gt; <span style="color: #800080;">4</span><span style="color: #000000;">}
  hbase</span>&gt; t.<span style="color: #0000ff;">get</span> <span style="color: #800000;">'</span><span style="color: #800000;">r1</span><span style="color: #800000;">'</span>, {FILTER =&gt; <span style="color: #800000;">"</span><span style="color: #800000;">ValueFilter(=, 'binary:abc')</span><span style="color: #800000;">"</span><span style="color: #000000;">}
  hbase</span>&gt; t.<span style="color: #0000ff;">get</span> <span style="color: #800000;">'</span><span style="color: #800000;">r1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">c1</span><span style="color: #800000;">'</span><span style="color: #000000;">
  hbase</span>&gt; t.<span style="color: #0000ff;">get</span> <span style="color: #800000;">'</span><span style="color: #800000;">r1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">c1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">c2</span><span style="color: #800000;">'</span><span style="color: #000000;">
  hbase</span>&gt; t.<span style="color: #0000ff;">get</span> <span style="color: #800000;">'</span><span style="color: #800000;">r1</span><span style="color: #800000;">'</span>, [<span style="color: #800000;">'</span><span style="color: #800000;">c1</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">c2</span><span style="color: #800000;">'</span><span style="color: #000000;">]
  hbase</span>&gt; t.<span style="color: #0000ff;">get</span> <span style="color: #800000;">'</span><span style="color: #800000;">r1</span><span style="color: #800000;">'</span>, {CONSISTENCY =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">TIMELINE</span><span style="color: #800000;">'</span><span style="color: #000000;">}
  hbase</span>&gt; t.<span style="color: #0000ff;">get</span> <span style="color: #800000;">'</span><span style="color: #800000;">r1</span><span style="color: #800000;">'</span>, {CONSISTENCY =&gt; <span style="color: #800000;">'</span><span style="color: #800000;">TIMELINE</span><span style="color: #800000;">'</span>, REGION_REPLICA_ID =&gt; <span style="color: #800080;">1</span><span style="color: #000000;">}
</span><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">075</span> &gt; </pre>
</div>
<span class="cnblogs_code_collapse">View Code</span></div>
<p>获取 user 表中 row key 为 user0001 的所有信息</p>
<div class="cnblogs_code">
<pre><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">072</span> &gt; <span style="color: #0000ff;">get</span> <span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">user0001</span><span style="color: #800000;">'</span><span style="color: #000000;">
COLUMN                                     CELL                                                                                                                        
 base_info:name                            timestamp</span>=<span style="color: #800080;">1534250570112</span>, value=<span style="color: #000000;">zhangsan1                                                                                    
</span><span style="color: #800080;">1</span> row(s) <span style="color: #0000ff;">in</span> <span style="color: #800080;">0.1060</span><span style="color: #000000;"> seconds

</span><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">073</span> &gt; </pre>
</div>
<p>获取user表中row key为user0001，base_info列簇的所有信息</p>
<div class="cnblogs_code">
<pre><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">073</span> &gt; <span style="color: #0000ff;">get</span> <span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">user0001</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">base_info</span><span style="color: #800000;">'</span><span style="color: #000000;">
COLUMN                                     CELL                                                                                                                        
 base_info:name                            timestamp</span>=<span style="color: #800080;">1534250570112</span>, value=<span style="color: #000000;">zhangsan1                                                                                    
</span><span style="color: #800080;">1</span> row(s) <span style="color: #0000ff;">in</span> <span style="color: #800080;">0.0830</span><span style="color: #000000;"> seconds

</span><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">074</span> &gt; </pre>
</div>
<p>查询user_info表中的所有信息</p>
<div class="cnblogs_code">
<pre><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">075</span> &gt; scan <span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span></pre>
</div>
<div class="cnblogs_code" onclick="cnblogs_code_show('afd4d2a4-c6b2-4fdd-bb4b-324ddd365cca')"><img id="code_img_closed_afd4d2a4-c6b2-4fdd-bb4b-324ddd365cca" class="code_img_closed" src="https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif" alt="" /><img id="code_img_opened_afd4d2a4-c6b2-4fdd-bb4b-324ddd365cca" class="code_img_opened" style="display: none;" onclick="cnblogs_code_hide('afd4d2a4-c6b2-4fdd-bb4b-324ddd365cca',event)" src="https://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif" alt="" />
<div id="cnblogs_code_open_afd4d2a4-c6b2-4fdd-bb4b-324ddd365cca" class="cnblogs_code_hide">
<pre>ROW                                        COLUMN+<span style="color: #000000;">CELL                                                                                                                 
 baiyc_20150716_0001                       column</span>=base_info:age, timestamp=<span style="color: #800080;">1534250642273</span>, value=<span style="color: #800080;">21</span><span style="color: #000000;">                                                                     
 baiyc_20150716_0001                       column</span>=base_info:name, timestamp=<span style="color: #800080;">1534250641636</span>, value=<span style="color: #000000;">baiyc1                                                                
 baiyc_20150716_0001                       column</span>=extra_info:Hobbies, timestamp=<span style="color: #800080;">1534250642780</span>, value=<span style="color: #000000;">music                                                             
 baiyc_20150716_0002                       column</span>=base_info:age, timestamp=<span style="color: #800080;">1534250642396</span>, value=<span style="color: #800080;">22</span><span style="color: #000000;">                                                                     
 baiyc_20150716_0002                       column</span>=base_info:name, timestamp=<span style="color: #800080;">1534250641676</span>, value=<span style="color: #000000;">baiyc2                                                                
 baiyc_20150716_0002                       column</span>=extra_info:Hobbies, timestamp=<span style="color: #800080;">1534250642826</span>, value=<span style="color: #000000;">sport                                                             
 baiyc_20150716_0003                       column</span>=base_info:age, timestamp=<span style="color: #800080;">1534250642438</span>, value=<span style="color: #800080;">23</span><span style="color: #000000;">                                                                     
 baiyc_20150716_0003                       column</span>=base_info:name, timestamp=<span style="color: #800080;">1534250641719</span>, value=<span style="color: #000000;">baiyc3                                                                
 baiyc_20150716_0003                       column</span>=extra_info:Hobbies, timestamp=<span style="color: #800080;">1534250642869</span>, value=<span style="color: #000000;">music                                                             
 baiyc_20150716_0004                       column</span>=base_info:age, timestamp=<span style="color: #800080;">1534250642499</span>, value=<span style="color: #800080;">24</span><span style="color: #000000;">                                                                     
 baiyc_20150716_0004                       column</span>=base_info:name, timestamp=<span style="color: #800080;">1534250641787</span>, value=<span style="color: #000000;">baiyc4                                                                
 baiyc_20150716_0004                       column</span>=extra_info:Hobbies, timestamp=<span style="color: #800080;">1534250642913</span>, value=<span style="color: #000000;">sport                                                             
 baiyc_20150716_0005                       column</span>=base_info:age, timestamp=<span style="color: #800080;">1534250642555</span>, value=<span style="color: #800080;">25</span><span style="color: #000000;">                                                                     
 baiyc_20150716_0005                       column</span>=base_info:name, timestamp=<span style="color: #800080;">1534250641855</span>, value=<span style="color: #000000;">baiyc5                                                                
 baiyc_20150716_0005                       column</span>=extra_info:Hobbies, timestamp=<span style="color: #800080;">1534250642971</span>, value=<span style="color: #000000;">music                                                             
 baiyc_20150716_0006                       column</span>=base_info:age, timestamp=<span style="color: #800080;">1534250642607</span>, value=<span style="color: #800080;">26</span><span style="color: #000000;">                                                                     
 baiyc_20150716_0006                       column</span>=base_info:name, timestamp=<span style="color: #800080;">1534250641906</span>, value=<span style="color: #000000;">baiyc6                                                                
 baiyc_20150716_0006                       column</span>=extra_info:Hobbies, timestamp=<span style="color: #800080;">1534250643032</span>, value=<span style="color: #000000;">sport                                                             
 baiyc_20150716_0007                       column</span>=base_info:age, timestamp=<span style="color: #800080;">1534250642655</span>, value=<span style="color: #800080;">27</span><span style="color: #000000;">                                                                     
 baiyc_20150716_0007                       column</span>=base_info:name, timestamp=<span style="color: #800080;">1534250641967</span>, value=<span style="color: #000000;">baiyc7                                                                
 baiyc_20150716_0007                       column</span>=extra_info:Hobbies, timestamp=<span style="color: #800080;">1534250643075</span>, value=<span style="color: #000000;">music                                                             
 baiyc_20150716_0008                       column</span>=base_info:age, timestamp=<span style="color: #800080;">1534250642709</span>, value=<span style="color: #800080;">28</span><span style="color: #000000;">                                                                     
 baiyc_20150716_0008                       column</span>=base_info:name, timestamp=<span style="color: #800080;">1534250642082</span>, value=<span style="color: #000000;">baiyc8                                                                
 baiyc_20150716_0008                       column</span>=extra_info:Hobbies, timestamp=<span style="color: #800080;">1534250674681</span>, value=<span style="color: #000000;">sport                                                             
 user0001                                  column</span>=base_info:name, timestamp=<span style="color: #800080;">1534250570112</span>, value=<span style="color: #000000;">zhangsan1                                                             
 zhangsan_20150701_0001                    column</span>=base_info:age, timestamp=<span style="color: #800080;">1534250640240</span>, value=<span style="color: #800080;">21</span><span style="color: #000000;">                                                                     
 zhangsan_20150701_0001                    column</span>=base_info:name, timestamp=<span style="color: #800080;">1534250639664</span>, value=<span style="color: #000000;">zhangsan1                                                             
 zhangsan_20150701_0001                    column</span>=extra_info:Hobbies, timestamp=<span style="color: #800080;">1534250641009</span>, value=<span style="color: #000000;">music                                                             
 zhangsan_20150701_0002                    column</span>=base_info:age, timestamp=<span style="color: #800080;">1534250640310</span>, value=<span style="color: #800080;">22</span><span style="color: #000000;">                                                                     
 zhangsan_20150701_0002                    column</span>=base_info:name, timestamp=<span style="color: #800080;">1534250639746</span>, value=<span style="color: #000000;">zhangsan2                                                             
 zhangsan_20150701_0002                    column</span>=extra_info:Hobbies, timestamp=<span style="color: #800080;">1534250641078</span>, value=<span style="color: #000000;">sport                                                             
 zhangsan_20150701_0003                    column</span>=base_info:age, timestamp=<span style="color: #800080;">1534250640367</span>, value=<span style="color: #800080;">23</span><span style="color: #000000;">                                                                     
 zhangsan_20150701_0003                    column</span>=base_info:name, timestamp=<span style="color: #800080;">1534250639808</span>, value=<span style="color: #000000;">zhangsan3                                                             
 zhangsan_20150701_0003                    column</span>=extra_info:Hobbies, timestamp=<span style="color: #800080;">1534250641226</span>, value=<span style="color: #000000;">music                                                             
 zhangsan_20150701_0004                    column</span>=base_info:age, timestamp=<span style="color: #800080;">1534250640439</span>, value=<span style="color: #800080;">24</span><span style="color: #000000;">                                                                     
 zhangsan_20150701_0004                    column</span>=base_info:name, timestamp=<span style="color: #800080;">1534250639866</span>, value=<span style="color: #000000;">zhangsan4                                                             
 zhangsan_20150701_0004                    column</span>=extra_info:Hobbies, timestamp=<span style="color: #800080;">1534250641291</span>, value=<span style="color: #000000;">sport                                                             
 zhangsan_20150701_0005                    column</span>=base_info:age, timestamp=<span style="color: #800080;">1534250640540</span>, value=<span style="color: #800080;">25</span><span style="color: #000000;">                                                                     
 zhangsan_20150701_0005                    column</span>=base_info:name, timestamp=<span style="color: #800080;">1534250639931</span>, value=<span style="color: #000000;">zhangsan5                                                             
 zhangsan_20150701_0005                    column</span>=extra_info:Hobbies, timestamp=<span style="color: #800080;">1534250641357</span>, value=<span style="color: #000000;">music                                                             
 zhangsan_20150701_0006                    column</span>=base_info:age, timestamp=<span style="color: #800080;">1534250640648</span>, value=<span style="color: #800080;">26</span><span style="color: #000000;">                                                                     
 zhangsan_20150701_0006                    column</span>=base_info:name, timestamp=<span style="color: #800080;">1534250640025</span>, value=<span style="color: #000000;">zhangsan6                                                             
 zhangsan_20150701_0006                    column</span>=extra_info:Hobbies, timestamp=<span style="color: #800080;">1534250641446</span>, value=<span style="color: #000000;">sport                                                             
 zhangsan_20150701_0007                    column</span>=base_info:age, timestamp=<span style="color: #800080;">1534250640743</span>, value=<span style="color: #800080;">27</span><span style="color: #000000;">                                                                     
 zhangsan_20150701_0007                    column</span>=base_info:name, timestamp=<span style="color: #800080;">1534250640097</span>, value=<span style="color: #000000;">zhangsan7                                                             
 zhangsan_20150701_0007                    column</span>=extra_info:Hobbies, timestamp=<span style="color: #800080;">1534250641547</span>, value=<span style="color: #000000;">music                                                             
 zhangsan_20150701_0008                    column</span>=base_info:age, timestamp=<span style="color: #800080;">1534250640872</span>, value=<span style="color: #800080;">28</span><span style="color: #000000;">                                                                     
 zhangsan_20150701_0008                    column</span>=base_info:name, timestamp=<span style="color: #800080;">1534250640149</span>, value=<span style="color: #000000;">zhangsan8                                                             
</span><span style="color: #800080;">17</span> row(s) <span style="color: #0000ff;">in</span> <span style="color: #800080;">0.3440</span><span style="color: #000000;"> seconds

</span><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">076</span> &gt; </pre>
</div>
<span class="cnblogs_code_collapse">View Code</span></div>
<p>查询user_info表中列簇为base_info的信息</p>
<div class="cnblogs_code">
<p>&nbsp; 1.8.7-p357 :076 &gt; scan 'user_info', {COLUMNS =&gt; 'base_info'}</p>
</div>
<h3>3、删delete&nbsp;&nbsp;</h3>
<p>删除user_info表row key为user0001，列标示符为base_info:name的数据</p>
<div class="cnblogs_code">
<pre><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">077</span> &gt; delete <span style="color: #800000;">'</span><span style="color: #800000;">user_info</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">user0001</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">base_info:name</span><span style="color: #800000;">'</span>
<span style="color: #800080;">0</span> row(s) <span style="color: #0000ff;">in</span> <span style="color: #800080;">0.0650</span><span style="color: #000000;"> seconds

</span><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">078</span> &gt;</pre>
</div>
<h2>四、HBase常用命令</h2>
<p>HBase常用命令status, version, table_help和whoami。本章将介绍了这些命令。</p>
<h3>1、status</h3>
<p>命令返回包括在系统上运行的服务器的细节和系统的状态。它的语法如下：如果执行这个命令，它会返回下面的输出</p>
<div class="cnblogs_code">
<pre><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">078</span> &gt;<span style="color: #000000;"> status 
</span><span style="color: #800080;">1</span> active master, <span style="color: #800080;">1</span> backup masters, <span style="color: #800080;">3</span> servers, <span style="color: #800080;">0</span> dead, <span style="color: #800080;">1.6667</span> average load</pre>
</div>
<h3>2、version</h3>
<p>该命令返回HBase系统使用的版本。它的语法如下：如果执行这个命令，它会返回下面的输出。</p>
<div class="cnblogs_code">
<pre><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">079</span> &gt;<span style="color: #000000;"> version
</span><span style="color: #800080;">1.2</span>.<span style="color: #800080;">6</span>, rUnknown, Mon May <span style="color: #800080;">29</span> <span style="color: #800080;">02</span>:<span style="color: #800080;">25</span>:<span style="color: #800080;">32</span> CDT <span style="color: #800080;">2017</span></pre>
</div>
<h3>3、table_help</h3>
<p>此命令将引导如何使用表引用的命令。下面给出的是使用这个命令的语法。当使用此命令时，它显示帮助主题表相关的命令。</p>
<div class="cnblogs_code">
<pre>1.8.7-p357 :080 &gt;<span style="color: #000000;"> table_help
Help </span><span style="color: #0000ff;">for</span> table-<span style="color: #000000;">reference commands.

You can either create a table via </span><span style="color: #800000;">'</span><span style="color: #800000;">create</span><span style="color: #800000;">'</span> and then manipulate the table via commands like <span style="color: #800000;">'</span><span style="color: #800000;">put</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">get</span><span style="color: #800000;">'</span><span style="color: #000000;">, etc.
See the standard help information </span><span style="color: #0000ff;">for</span><span style="color: #000000;"> how to use each of these commands.

However, </span><span style="color: #0000ff;">as</span> of <span style="color: #800080;">0.96</span>, you can also <span style="color: #0000ff;">get</span><span style="color: #000000;"> a reference to a table, on which you can invoke commands.
For instance, you can </span><span style="color: #0000ff;">get</span><span style="color: #000000;"> create a table and keep around a reference to it via:

   hbase</span>&gt; t = create <span style="color: #800000;">'</span><span style="color: #800000;">t</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">cf</span><span style="color: #800000;">'</span><span style="color: #000000;">

Or, </span><span style="color: #0000ff;">if</span> you have already created the table, you can <span style="color: #0000ff;">get</span><span style="color: #000000;"> a reference to it:

   hbase</span>&gt; t = get_table <span style="color: #800000;">'</span><span style="color: #800000;">t</span><span style="color: #800000;">'</span><span style="color: #000000;">

You can </span><span style="color: #0000ff;">do</span> things like call <span style="color: #800000;">'</span><span style="color: #800000;">put</span><span style="color: #800000;">'</span><span style="color: #000000;"> on the table:

  hbase</span>&gt; t.put <span style="color: #800000;">'</span><span style="color: #800000;">r</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">cf:q</span><span style="color: #800000;">'</span>, <span style="color: #800000;">'</span><span style="color: #800000;">v</span><span style="color: #800000;">'</span><span style="color: #000000;">

which puts a row </span><span style="color: #800000;">'</span><span style="color: #800000;">r</span><span style="color: #800000;">'</span> with column family <span style="color: #800000;">'</span><span style="color: #800000;">cf</span><span style="color: #800000;">'</span>, qualifier <span style="color: #800000;">'</span><span style="color: #800000;">q</span><span style="color: #800000;">'</span> and value <span style="color: #800000;">'</span><span style="color: #800000;">v</span><span style="color: #800000;">'</span><span style="color: #000000;"> into table t.

To read the data </span><span style="color: #0000ff;">out</span><span style="color: #000000;">, you can scan the table:

  hbase</span>&gt;<span style="color: #000000;"> t.scan

which will read all the rows </span><span style="color: #0000ff;">in</span> table <span style="color: #800000;">'</span><span style="color: #800000;">t</span><span style="color: #800000;">'</span><span style="color: #000000;">.

Essentially, any command that takes a table name can also be done via table reference.
Other commands include things like: </span><span style="color: #0000ff;">get</span><span style="color: #000000;">, delete, deleteall,
get_all_columns, get_counter, count, incr. These functions, along with
the standard JRuby </span><span style="color: #0000ff;">object</span><span style="color: #000000;"> methods are also available via tab completion.

For more information on how to use each of these commands, you can also just type:

   hbase</span>&gt; t.help <span style="color: #800000;">'</span><span style="color: #800000;">scan</span><span style="color: #800000;">'</span><span style="color: #000000;">

which will output more information on how to use that command.

You can also </span><span style="color: #0000ff;">do</span><span style="color: #000000;"> general admin actions directly on a table; things like enable, disable,
flush and drop just by typing:

   hbase</span>&gt;<span style="color: #000000;"> t.enable
   hbase</span>&gt;<span style="color: #000000;"> t.flush
   hbase</span>&gt;<span style="color: #000000;"> t.disable
   hbase</span>&gt;<span style="color: #000000;"> t.drop

Note that after dropping a table, your reference to it becomes useless and further usage
</span><span style="color: #0000ff;">is</span> undefined (and not recommended).</pre>
</div>
<h3>4、whoami</h3>
<p>该命令返回HBase用户详细信息。如果执行这个命令，返回当前HBase用户，如下图所示</p>
<div class="cnblogs_code">
<pre><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">081</span> &gt;<span style="color: #000000;"> whoami
admin (auth:SIMPLE)
    groups: admin

</span><span style="color: #800080;">1.8</span>.<span style="color: #800080;">7</span>-p357 :<span style="color: #800080;">082</span> &gt;</pre>
</div>
<p>&nbsp;</p></div><div id="MySignature"></div>

</body>
</html>
